package com.yidu.logisticssystem.service.impl;

import com.yidu.logisticssystem.entity.LogisticsCar;
import com.yidu.logisticssystem.entity.LogisticsCardriver;
import com.yidu.logisticssystem.dao.LogisticsCardriverDao;
import com.yidu.logisticssystem.entity.vo.CarDriverVo;
import com.yidu.logisticssystem.entity.vo.CarVo;
import com.yidu.logisticssystem.service.LogisticsCardriverService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (LogisticsCardriver)表服务实现类
 *
 * @author makejava
 * @since 2021-03-17 09:49:49
 */
@Service("logisticsCardriverService")
public class LogisticsCardriverServiceImpl implements LogisticsCardriverService {
    @Resource
    private LogisticsCardriverDao logisticsCardriverDao;

    /**
     * 通过ID查询单条数据
     *
     * @param driverId 主键
     * @return 实例对象
     */
    @Override
    public LogisticsCardriver queryById(Integer driverId) {
        return this.logisticsCardriverDao.queryById(driverId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<LogisticsCardriver> queryAllByLimit(int offset, int limit) {
        return this.logisticsCardriverDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param logisticsCardriver 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsCardriver insert(LogisticsCardriver logisticsCardriver) {
        this.logisticsCardriverDao.insert(logisticsCardriver);
        return logisticsCardriver;
    }

    /**
     * 修改数据
     *
     * @param logisticsCardriver 实例对象
     * @return 实例对象
     */
    @Override
    public LogisticsCardriver update(LogisticsCardriver logisticsCardriver) {
        this.logisticsCardriverDao.update(logisticsCardriver);
        return this.queryById(logisticsCardriver.getDriverId());
    }

    /**
     * 通过主键删除数据
     *
     * @param driverId 主键
     * @return 是否成功
     */
    @Override
    public int deleteById(Integer driverId) {
        return this.logisticsCardriverDao.deleteById(driverId);
    }

    /**
     * 查询全部
     * @param carDriverVo
     * @return
     */
    @Override
    public List<CarDriverVo> queryAll(CarDriverVo carDriverVo) {
        return this.logisticsCardriverDao.queryAll(carDriverVo);
    }

    /**
     * 新增
     * @param logisticsCardriver
     * @return
     */
    @Override
    public int insertSelective(LogisticsCardriver logisticsCardriver) {
        return this.logisticsCardriverDao.insertSelective(logisticsCardriver);
    }

    /**
     * 批量删除
     * @param ids
     * @return
     */
    @Override
    public int deleteAll(String ids) {
        //将,分隔的字符串分隔成数组,传入到dao中
        String [] idArray = ids.split(",");
        return logisticsCardriverDao.deleteAll(idArray);
    }

    /**
     * 查询空闲司机
     * @param mapId 主键
     * @return
     */
    @Override
    public List<CarDriverVo> queryMapId(String mapId) {
        return this.logisticsCardriverDao.queryMapId(mapId);
    }

    /**
     * 根据司机id修改
     * @param logisticsCardriver
     * @return
     */
    @Override
    public int updateCarId(LogisticsCardriver logisticsCardriver) {
        return this.logisticsCardriverDao.updateCarId(logisticsCardriver);
    }


}
